/**
 * 权限相关的工具
 */
const TOKEN_SIGN = 'AccessToken'

export function getToken () {
	return new Promise(resolve => {
		uni.getStorage({
			key: TOKEN_SIGN,
			success: (res) => {
				const token = res.data
				return resolve(token)
			},
			fail: () => {
				return resolve(false)
			}
		})
	})
}

export function setToken (token) {
	return new Promise(resolve => {
		uni.setStorage({
			key: TOKEN_SIGN,
			data: token,
			success: () => {
				return resolve(true)
			},
			fail: () => {
				return resolve(false)
			}
		})
	})
}

export function removeToken () {
	return new Promise(resolve => {
		uni.removeStorage({
			key: TOKEN_SIGN,
			success: () => {
				return resolve(true)
			},
			fail: () => {
				return resolve(false)
			}
		})
	})
}